Skip to main content

Remove Audit subscription

This endpoint will remove the existing audit subscription record from the database and stop the current streaming process. Please note, to restart the subscription, call the subscribe endpoint again.

URL : http://34.122.70.8/api/v1/audit/unsubscribe

Method : DELETE

Auth required : YES

HeadersTypeDescription
api-keystringUnique api key provided to each customer

Permissions required : None

Data constraints

Provide info including where the service should forward the Audit Records, the maximum number of records in each payload, and the frequency for sending them.

Response Body:

FieldTypeDescription
statusBooleanStatus of the request
msgstringResponse message from the server
dataData Object

Data Object:

FieldTypeDescription
idstringID of the audit subscription table record
start_timeDateDate and time from when Audit Records should be fetched
last_read_atData ObjectTime of the last Audit Record sent via the subscription
endpoint_urlstringClient webhook URL where data is being sent
fetch_limitstringMax number of Audit Records to be sent to the client in each message
read_intervalNumberInterval, in seconds, between messages sent to the client
statusstringStatus of the subscription. For new subscription, the status will be 'active'.
createdAtDateDate and time subscription was created
updatedAtData ObjectDate and time subscription was last updated

Success Response

Condition : If everything is OK and and the subscription does not already exist.

Code : 200 OK

Content example

{
"status": true,
"msg": "Audit record unsubscribed successfully",
"data": [
{
"id": 1,
"start_time": "2022-12-25T07:03:30.000Z",
"last_read_at": null,
"endpoint_url": "http://localhost:3000/hook",
"fetch_limit": 100,
"read_interval": 60,
"status": "active",
"createdAt": "2023-07-12T17:51:58.439Z",
"updatedAt": "2023-07-12T17:51:58.439Z"
}
]
}

Error Responses

Condition : If no subscription exists.

Code : 200 OK

Content :

{
"status": true,
"msg": "Audit record unsubscribed successfully",
"data": []
}

Or

Condition : If api-key is not passed in request header or is wrong.

Code : 401 Unauthorized

Content example

{
"status": false,
"error_code": "AUDIT_UNAUTHORIZED",
"error_msg": "Missing/MisMatch API KEY"
}
const fetch = require('node-fetch');

let url = 'http://34.122.70.8/api/v1/audit/unsubscribe';

let options = {method: 'DELETE', headers: {'api-key': '<API_KEY>'}};

fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));